var Action = require("../apiaction");
var Utility = require("../Utility/utility.js");
exports.mallAPI = function(router){


    //材料菜单
    //一级菜单列表获取
    router.all('/mall/GetMaterialTypeList', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        //console.log(params);

        Action.send(req, res, "/mall/GetMaterialTypeList", params, function (res, data) {


            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mall/add', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mall/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mall/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //二级材料列表
    //列表获取
    router.all('/mall/getMaterialListPaging', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/getMaterialListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mall/addMaterial', function (req, res) {

        var params = {name: req.param("name"),type_id: req.param("type_id"),pic_url: req.param("pic_url")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/addMaterial", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mall/updateMaterial', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id"),type_id: req.param("type_id"),pic_url: req.param("pic_url")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/updateMaterial", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mall/deleteMaterial', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mall/deleteMaterial", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //商品属性
    //列表获取
    router.all('/mallattr/getListPaging', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mallattr/add', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mallattr/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallattr/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //商品属性内容
    //列表获取
    router.all('/mallattr/getContentListPaging', function (req, res) {

        var params = {attr_id: req.param("attr_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/getContentListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/mallattr/addContent', function (req, res) {

        var params = {attr_id: req.param("attr_id"),content: req.param("content")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/addContent", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mallattr/updateContent', function (req, res) {

        var params = {content: req.param("content"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/updateContent", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallattr/deleteContent', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallattr/deleteContent", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //商品属性模板
    //列表获取
    router.all('/mallTemplate/getListPaging', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallTemplate/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mallTemplate/add', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallTemplate/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mallTemplate/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallTemplate/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallTemplate/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallTemplate/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //商品品牌
    //列表获取
    router.all('/mallBrands/getListPaging', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mallBrands/add', function (req, res) {

        var params = {name: req.param("name"),pic_url: req.param("pic_url"),introduction: req.param("introduction")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mallBrands/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id"),pic_url: req.param("pic_url"),introduction: req.param("introduction")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallBrands/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //品牌对应材料
    //列表获取
    router.all('/mallBrands/getBrandsListPaging', function (req, res) {

        var params = {material_id: req.param("material_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/getBrandsListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mallBrands/addBrands', function (req, res) {

        var params = {material_id: req.param("material_id"),brands_id: req.param("brands_id"),type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/addBrands", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallBrands/deleteBrands', function (req, res) {

        var params = {material_id: req.param("material_id"),brands_id: req.param("brands_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallBrands/deleteBrands", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //商铺
    //列表获取
    router.all('/mallShop/getListPaging', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallShop/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //添加
    router.all('/mallShop/add', function (req, res) {

        var params = {name: req.param("name"),logo: req.param("logo"),mobile: req.param("mobile"),address: req.param("address")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallShop/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //更新
    router.all('/mallShop/update', function (req, res) {

        var params = {name: req.param("name"), obj_id: req.param("obj_id"),logo: req.param("logo"),mobile: req.param("mobile"),address: req.param("address")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallShop/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //删除
    router.all('/mallShop/delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallShop/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //商品
    //列表获取
    router.all('/mallGoods/getListPaging', function (req, res) {

        var params = {type_id: req.param("type_id"),material_id: req.param("material_id"),brands_id: req.param("brands_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallGoods/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //商品规格
    //列表获取
    router.all('/mallSpec/getListPaging', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpec/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/mallSpec/add', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark"),type: req.param("type"),unit_id: req.param("unit_id"), unit_name: req.param("unit_name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpec/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/mallSpec/update', function (req, res) {

        var params = {obj_id: req.param("obj_id"),name: req.param("name"),remark: req.param("remark"),type: req.param("type"),unit_id: req.param("unit_id"), unit_name: req.param("unit_name")};


        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpec/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/mallSpec/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpec/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //商品属性

    //列表获取
    router.all('/mallAttrs/getListPaging', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallAttrs/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/mallAttrs/add', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallAttrs/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/mallAttrs/update', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark"), obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallAttrs/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/mallAttrs/Delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallAttrs/Delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //获取列表

    //列表获取
    router.all('/mallSpecAttrs/getListPaging', function (req, res) {

        var params = {specs_id: req.param("specs_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpecAttrs/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/mallSpecAttrs/delete', function (req, res) {

        var params = {specs_id: req.param("specs_id"),attrs_id: req.param("attrs_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpecAttrs/delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/mallSpecAttrs/add', function (req, res) {

        var params = {specs_id: req.param("specs_id"),attrs_id: req.param("attrs_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/mallSpecAttrs/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });







}